<?php
class Member_contactsAction extends IntesysAction {
	function index(){
		$this->dao = D('Member');
		$this->listmap="1";
		$this->getLevelNameList = $this->dao -> getLevelNameList();
		if($this->_get('keywords')&&($this->_get('keywords')!='')){
			$this->listmap .= " and (name like '%".$this->_get('keywords')."%' or id = '".$this->_get('keywords')."')";
			$this->keywords = $this->_get('keywords');
		}
		
		if($this->_get('level')){
			if($this->_get('level') != 'all'){
				$this->listmap .= " and (level = '".$this->_get('level')."')";
			}
			
			$this->level = $this->_get('level');
		}  
		$this->listmap.=" and site_id=".__SITEID__. '  ';//and pid = 0 

		if(isset($_GET['member_position_id'])){
			foreach($_GET['member_position_id'] as $v){
				$memberpositionstr[] = "memberpositionid like '%".$v."%'";
			}
			if(count($memberpositionstr) > 0){
			    $this->listmap.=" and (".implode(' or ', $memberpositionstr).")";
		    }
			//		var_dump($this->listmap);exit;
		}else{
			$this->listmap.=" and memberpositionid<>''";
		}
		

		
		
		
        parent::_list();
		/*$list = $this->get('list');
		foreach($list as $k => $v){
		    //$list[$k]['sub'] = $this -> dao -> getListToArray1($v['id'], __SITEID__);
			$list[$k]['level'] = $this->dao->getLevelName($v['id']);
		}
		$this->assign('list', $list);*/
		$map['site_id'] = __SITEID__;
		$coupons = M('coupon')->where($map)->select();
		$this->assign("coupons",$coupons);
		
		$this->groupList=M('member_group')->where(['site_id'=>__SITEID__])->getField('id,title');
		$this->positionList=M('member_position')->where(['site_id'=>__SITEID__])->getField('id,name');
		
		$this->display();
	}
}

